	function initialize(owner) { 
    	map = new google.maps.Map(document.getElementById("map_canvas"), {
    			zoom: 17,
			
    			center: new google.maps.LatLng(45.912543, 6.125897),
			
    			mapTypeId: google.maps.MapTypeId.ROADMAP
			
          });
    	
    	addBuildings(owner);
    	
		if (navigator.geolocation) {
	    	watchPlayerPosition();

		}else {
			alert("Votre navigateur ne prend pas en compte la géolocalisation HTML5");
		
		}
	  
    }
	
	function addBuildings(owner) {
  		window['Wallaw'] = new google.maps.Marker({
  			position: new google.maps.LatLng(45.904154,6.138273),
  			map: map,
  			title: 'Wallaw',
  			icon : 'Medias/buildings/wallaw.png',
  		});
  		
  		var content = "";
  		if ('' != owner) {
  			content += "<span>The wall is owned by "+ owner +" team.</span><br/>";
  			
  		}
  		
	      google.maps.event.addListener(window['Wallaw'], 'click', function() {
	    	  var position = this.getPosition();

		      window['infowindow_wallaw'] = new google.maps.InfoWindow({
		    	  content: content + "<span><a href='wallaw.php'>Conquer the wall !</a></span>"
		      });
		      
		      window['infowindow_wallaw'].open(map, this);
  	  
	      });
		
	}

	function watchPlayerPosition()  {
		var watchId = navigator.geolocation.getCurrentPosition(successPlayerPosition,
		                                  					errorCallback,
		                                  						{enableHighAccuracy:true,
		                                  						timeout:10000,
		                                  						maximumAge:0});
	
	}
	
	function successPlayerPosition(position){
		map.center = new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
		addMainPlayer(position);
	
	}
	
	function addMainPlayer(position) {
	       you = new google.maps.Marker({
	          	position: new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
	          	map: map,
	          	title: 'you',
	      });
		
	}
		 
	function stopGeolocation (){
		navigator.geolocation.clearWatch(watchId);
	}     
		 

		 
	function errorCallback(error){
		switch(error.code){
			case error.PERMISSION_DENIED:
				alert("L'utilisateur n'a pas autorisé l'accès à sa position");
				break;
			case error.POSITION_UNAVAILABLE:
				alert("L'emplacement de l'utilisateur n'a pas pu être déterminé");
				break;
			case error.TIMEOUT:
				alert("Le service n'a pas répondu à temps");
				break;
		}

	};
	
	

	
